﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Manage/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Company.Web.Areas.Manage.Models.MessageModels.IndexModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	留言管理
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
    <% Html.BeginForm(); %>
    <table width="100%" class="table">
        <tr class="bar"><th align="left" colspan="9">&nbsp;&nbsp;查找条件</th></tr>
        <tr>
            <td width="50px" align="right"><label for="Serch_Title">名字：</label></td>
            <td align="left" width="220px"><%=Html.TextBoxFor(p=>p.Serch.Name) %></td>
            <td width="50px" align="right"><label for="Serch_Language">状态：</label></td>
            <td align="left" width="80px"><%=Html.DropDownListFor(p=>p.Serch.State,Model.States) %></td>
            <td width="100px" align="right"><label for="Serch_StartTime">启始日期：</label></td>
            <td align="left"><input type="text" onclick = "WdatePicker()"  value='<%=string.Format("{0:yyyy-MM-dd}",Model.Serch.StartTime) %>' class="w80" name="Serch.StartTime" id="Serch_StartTime" /></td>
            <td rowspan="2"><input name="BtnSerch" type="submit" value="查找" /></td>
        </tr>
        <tr>
            <td width="50px" align="right"><label for="Serch_Title">标题：</label></td>
            <td align="left" width="220px"><%=Html.TextBoxFor(p=>p.Serch.Title) %></td>
            <td width="50px" align="right"><label for="Serch_Language">语言：</label></td>
            <td align="left" width="80px"><%=Html.DropDownListFor(p=>p.Serch.Language,Model.Languages) %></td>
            <td width="100px" align="right"><label for="Serch_EndTime">终止日期：</label></td>
            <td align="left"><input type="text" onclick = "WdatePicker()"  value='<%=string.Format("{0:yyyy-MM-dd}",Model.Serch.EndTime) %>' class="w80" name="Serch.EndTime" id="Serch_EndTime" /></td>
       </tr>
    </table>
    <p />
    <table width="100%" class="table" id="items">
        <tr class="bar">
            <th width="120px">日期</th>
            <th width="100px">名称</th>
            <th width="150px">联系方式</th>
            <th>标题</th>
            <th width="30px">状态</th>
            <th width="50px">语言</th>
            <th width="80px">
                <label><input type="checkbox" onclick="var ck=this.checked; $('#items #MsgID').each(function(){ this.checked=ck;});" />全选</label>
            </th>
        </tr>
        <% foreach (var item in Model.Msgs) %>
        <% { %>
        <tr>
            <td><%=string.Format("{0:yyyy-MM-dd HH:mm}", item.AddTime) %></td>
            <td><%=Html.Encode(item.Name) %></td>
            <td><%=Html.Encode(item.ContactInfo) %></td>
            <td align="left"><% item.Content = Html.Encode(item.Content); string title = Html.Encode(Model.Serch.Title); %>
            <%=string.IsNullOrEmpty(Model.Serch.Title) ? item.Title : item.Title.Replace(title, "<span class='serchhight'>" + title + "</span>")%></td>
            <td id="itemstate"><%=item.State.Name() %></td>
            <td><%=item.Language.Name() %></td>
            <td>
                <%=Html.ActionLink("详情", "detail", new { item.ID }, new { id = "linkdetail" }) %>
                <input type="checkbox" id="MsgID" name="MsgID" value='<%=item.ID %>' />
            </td>
        </tr>
        <% } %>
        <% if (Model.SumCount == 0) %>
        <% { %>
        <tr><td colspan="7">无记录！</td></tr>
        <% } %>
        <% else %>
        <% { %>
        <tr>
            <td colspan="6"><%=Html.Pager(Model.ID, Model.A, Model.Size, Model.SumCount, "id", Url.Route(new { Model.Serch }), "a")%></td>
            <td><input type="submit" name="Del" value="删除选中" onclick="if($('#items #MsgID:checked').length > 0){return confirm('确定要删除吗？');}else{ alert('请先选中要删除的项！'); return false;}" /></td>
        </tr>
        <% } %>
    </table>
    <% Html.EndForm(); %>
</div>
<div class="dialog"></div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="StypeAndScript" runat="server">
    <style type="text/css">
        .serchhight{ color:#FDF786; font-weight:bold;}
        .typepath{ width:100%; }
        .typechilds { border-bottom:1px solid #888;}
        .typechilds,.typechilds ul{ height:auto; overflow:hidden;width:100%}
        .typechilds li{ height:25px; padding:3px 5px; width:150px; text-align:center; float:left;}
        .dialog{ display:none; text-align:left;}
        .dialog legend{ color:Black;}
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $("a#linkdetail").each(function () {
                var item = $(this);
                var url = this.href;
                item.click(function () {
                    $(".dialog").load(url, function (s, d, p) {
                        if (d == "error")
                            return false;
                        $.blockUI({ message: null });
                        var g =
                        {
                            closeText: '关闭',
                            title: '查看留言',
                            width: '600px',
                            height: '400px',
                            beforeClose: function () {
                                $.unblockUI();
                            },
                            buttons: {
                                "关闭": function () {
                                    $(this).dialog('close');
                                }
                            }
                        };
                        item.parent().parent().find("#itemstate").text('<%=MessageState.Read.Name() %>');
                        $(".dialog").dialog(g);
                    });
                    return false;
                });
            });
        });
    </script>
</asp:Content>